package com.example.easycharge.entity;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.text.SimpleDateFormat;
import java.util.Date;

@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
public class Report {
    @Id
    @Schema(description = "报告编号")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long reportId;
    @Schema(description = "充电桩编号")
    private long pileId;
    @Schema(description = "记录时间")
    private String recordDate;
    @Schema(description = "累计充电次数")
    private double chargeTime;
    @Schema(description = "累计工作时长")
    private int workHours;
    @Schema(description = "累计充电时长")
    private int chargeHours;
    // TODO: 2022-05-09 累计数据及时更新
    @Schema(description = "累计充电电量/度")
    private double chargeQuantity;
    @Schema(description = "累计充电费用")
    private double chargeBill;
    @Schema(description = "累计服务费用")
    private double serviceBill;
    @Schema(description = "累计总费用")
    private double totalBill;

    public Report(ChargePile chargePile) {
        Date date = new Date();
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
        recordDate = sf.format(date);

        pileId = chargePile.getChargePileId();
        chargeTime = chargePile.getChargeTime();
        workHours = chargePile.getWorkMinutes();
        chargeHours = chargePile.getChargeMinutes();
        chargeQuantity = chargePile.getChargeQuantity();
        chargeBill = chargePile.getChargeBill();
        serviceBill = chargePile.getServiceBill();
        totalBill = chargePile.getTotalBill();
    }
}
